import http, { RequestParams } from '@/utils/request';

class UserRequest {
  /**
   * 获取手机号一键登录
   * @param params
   * @constructor
   */
  public static GetPhone(params: RequestParams) {
    return http.get<string>('wx/v1/auth/getPhone', params);
  }

  /**
   * 手机号登录
   * @param params
   * @constructor
   */
  public static Login(params: RequestParams) {
    return http.post<ILoginResponse>('wx/v1/user/userLogin', params);
  }

  /**
   * 获取验证码
   * @param params
   * @constructor
   */
  public static FetchSMS(params: RequestParams) {
    return http.post('wx/v1/msg/sms', params);
  }

  /**
   * 更新用户信息
   * @param params
   * @constructor
   */
  public static UpdateUser(params: RequestParams) {
    return http.put<string>('wx/v1/user/setUserInfo', params);
  }

  /**
   * 更新用户手机号
   * @param params
   * @constructor
   */
  public static UpdateUserPhone(params: RequestParams) {
    return http.put<string>('wx/v1/user/setUserPhone', params);
  }

  /**
   * 获取地址列表
   * @param params
   * @constructor
   */
  public static ListShippingAddress(params: RequestParams) {
    return http.get<IListShippingAddressesRes[]>('wx/v1/userHarvestAddress/listByUser', params);
  }

  /**
   * 获取地址详情
   * @param params
   * @constructor
   */
  public static GetAddressDetails(params: RequestParams) {
    return http.get<IGetAddressDetailsRes>('wx/v1/userHarvestAddress', params);
  }

  /**
   * 保存收货地址
   * @param params
   * @constructor
   */
  public static SaveShippingAddress(params: RequestParams) {
    return http.post<number>('wx/v1/userHarvestAddress', params);
  }

  /**
   * 修改收货地址
   * @param params
   * @constructor
   */
  public static EditShippingAddress(params: RequestParams) {
    return http.put<number>('wx/v1/userHarvestAddress', params);
  }

  /**
   * 删除收货地址
   * @param params
   * @constructor
   */
  public static DeleteShippingAddress(params: RequestParams) {
    return http.put('wx/v1/userHarvestAddress/delete', params);
  }

  /**
   * 获取小区列表
   * @param params
   * @constructor
   */
  public static ResidentialAddressList(params: RequestParams) {
    return http.get<IResidentialAddressListRes[]>('wx/v1/village/listByName', params);
  }

  /**
   * 获取楼栋层树
   * @param params
   * @constructor
   */
  public static BuildingTree(params: RequestParams) {
    return http.get<IBuildingTreeRes[]>('wx/v1/villageArea/idNameTree', params);
  }

  /**
   * 获得紧急联系人
   * @param params
   * @constructor
   */
  public static GetUserContact(params: { userId: number }) {
    return http.get<IGetUserContactRes>('wx/v1/userContact', params);
  }

  /**
   * 修改紧急联系人
   * @param params
   * @constructor
   */
  public static UpdateUserContact(params: RequestParams) {
    return http.post('wx/v1/userContact/setUserContact', params);
  }

  /**
   * 是否开通邻里互助
   * @param params
   * @constructor
   */
  public static UpdateHelpFlag(params: RequestParams) {
    return http.put('wx/v1/userContact/setHelpFlag', params);
  }

  /**
   * 会员余额
   * @param params
   * @constructor
   */
  public static ListByCustomer(params: RequestParams) {
    return http.get<IListByCustomerRes[]>('wx/v1/member/listByCustomer', params);
  }

  /**
   * 获得积分
   * @param params
   * @constructor
   */
  public static GetPoints(params: RequestParams) {
    return http.get<number>('wx/v1/customerPointsRecord/getPoints', params);
  }

  /**
   * 积分账单中获得积分
   * @param params
   * @constructor
   */
  public static CountByMonth(params: RequestParams) {
    return http.get<{ expense: number; income: number }>('wx/v1/customerPointsRecord/countByMonth', params);
  }

  /**
   * 积分账单中获得积分列表
   * @param params
   * @constructor
   */
  public static PointsRecordList(params: RequestParams) {
    return http.get<IPointsRecordList>('wx/v1/customerPointsRecord/page', params);
  }

  /**
   * 积分管理信息获取
   * @param params
   * @constructor
   */
  public static GetUserIntegralAccount(params: RequestParams) {
    return http.get<IUserAccount | null>('wx/v1/userAccount', params);
  }

  /**
   * 获取资金数据
   * @param params
   * @constructor
   */
  public static GetMoneyInfo(params: RequestParams) {
    return http.get<IMoneyManagementInfo>('wx/v1/userAccount/getUserAccount', params);
  }

  //获取资金明细列表
  public static GetMoneyDetailList(params: RequestParams) {
    return http.get<IListRes<IMoneyManagementList>>('wx/v1/orderSplitInfo/page', params);
  }

  //获取分账详情
  public static GetMoneyDetailInfo(params: RequestParams) {
    return http.get<IMoneyManagementList>('wx/v1/orderSplitInfo', params);
  }

  //获取所有银行
  public static GetBankList(params: RequestParams) {
    return http.get<IListRes<IBankList[]>>('wx/v1/bankCode/pageBankCode', params);
  }

  //获取当前银行所有支行
  public static GetCurrentBankBranchList(params: RequestParams) {
    return http.get<IListRes<IBankBranchList>>('wx/v1/bankCode/pageBranchCode', params);
  }

  //提交收款账户信息
  public static SetCollectAccountInfo(params: RequestParams) {
    return http.post('wx/v1/accountInfo/setYmAccount', params);
  }

  //获取当前翼码收款账户信息
  public static GetCurrentYmAccountInfo(params: RequestParams) {
    return http.get<IYmAccountInfo>('wx/v1/accountInfo/getYmAccount', params);
  }

  //获取当前账户信息
  public static GetCurrentAccountInfo(params: RequestParams) {
    return http.get<null>('wx/v1/accountInfo', params);
  }

  //生成推广码
  public static CreateExtendCode(params: RequestParams) {
    return http.get<string>('wx/v1/customer/getPromoteCode', params);
  }

  //获取申请码列表
  public static GetExtendCodeList(params: RequestParams) {
    return http.get<IListRes<IUserStack>>('wx/v1/userStack/page', params);
  }

  //业务员认证
  public static SalesmanSubmit(params: RequestParams) {
    return http.put<null>('wx/v1/customer/bindingCmsSale', params);
  }

  //小区列表
  public static GetAreaList(params: RequestParams) {
    return http.get<IListRes<IAreaList>>('wx/v1/village/page', params);
  }

  //获取服务模版
  public static GetServerModel(params: RequestParams) {
    return http.get<IServerModelList[]>('wx/v1/serverModel/listIdName', params);
  }

  //生成申请码
  public static ApplyCode(params: RequestParams) {
    return http.post<null>('wx/v1/userStack', params);
  }

  //获取推广员列表
  public static GetPromotionUserList(params: RequestParams) {
    return http.get<IListRes<IPromotionUserList>>('wx/v1/customer/pagePromote', params);
  }

  /**
   * 通过Id获取小区列表
   * @param params
   * @constructor
   */
  public static AreaListIdName(params: RequestParams) {
    return http.get<IResidentialAddressListRes[]>('wx/v1/village/listIdName', params);
  }

  /**
   * 获取推广模版
   * @param params
   * @constructor
   */
  public static promotionModelList(params: RequestParams) {
    return http.get<IPromotionModelList[]>('wx/v1/promoteModel/listIdName', params);
  }
}

export default UserRequest;
